package com.qixin.total.controller;


import com.alibaba.fastjson.JSONObject;
import com.qixin.api.bean.ComPtUser;
import com.qixin.api.bean.ResultPage;
import com.qixin.api.bean.VoPage;
import com.qixin.api.service.ComPtUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by aa on 2018/10/27
 * 李许多.
 * 企业认证
 */
@Controller
@RequestMapping("/company")
public class ComPtUserController {
    private static final Logger logger = LoggerFactory.getLogger(ComPtUserController.class);
    @Autowired
    ComPtUserService comPtUserService;

    @RequestMapping("/main.html")
    public String carftl(){
        return "renzheng/company1";
    }

    @RequestMapping("/check.html")
    public String check(String url,Model model){
      System.out.println("url: "+url);
        model.addAttribute("url",url);
        return "/renzheng/check";

    }

    @RequestMapping("/select")
    @ResponseBody
    public ResultPage<ComPtUser> list(VoPage voPage) {
        ResultPage<ComPtUser> resultPage=comPtUserService.selectALL(voPage );
        return  resultPage;

    }
    @RequestMapping("/selectphone")
    @ResponseBody
    public ResultPage<ComPtUser> selectphone(VoPage voPage, Long phone) {
        Map map=new HashMap();
        map.put("phone",phone);
        ResultPage<ComPtUser> resultPage=comPtUserService.selectphone(voPage,phone);
        return  resultPage;
    }



    /**
    * 修改
     * @param param
     * @return
     */
    @RequestMapping("/updatecheck")
    @ResponseBody
    public  boolean updatecheck(String param){
      ComPtUser comPtUser = JSONObject.parseObject(param,ComPtUser.class);
        if(comPtUserService.updateById(comPtUser)){
            return  true;
        }else{
            return false;
        }
    }

}
